package gameLogic;

import java.util.ArrayList;
import java.util.Iterator;

public class StrategyFork extends Strategy {
	private int targetStatus; // [observer status] to search for

	public StrategyFork(Board b, BoardState s, Observer ob) {
		super(b, s, ob);

		if (side == BoardState.X) {
			targetStatus = 11;
		} else {
			targetStatus = 22;
		}
		
		//System.out.println("Strategy: type="+type+" targetStatus="+targetStatus+" targetSymbol="+targetSymbol);
	}

	@Override
	public Move[] getAllMove() {

		ArrayList<Move> moveList = new ArrayList<Move>();
		Iterator<Move> i = getAllAllowed().iterator();
		while (i.hasNext()) {
			Move m = new Move(i.next());
			m.v = side;
			if(ob.getMoveEffect(m, targetStatus) >= 2) // this is the "fork"
			{
				moveList.add(m);
			
				break;  // find only 1 solution
			}
		}
		return moveList.toArray(new Move[0]);
	}

	@Override
	protected int getPriority() {
		// winning has higher priority than blocking
		return 8;
	}

}
